package com.initialize.core.rabbit.config;

import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.context.annotation.Bean;

/**
 * Created By http://www.czesou.com
 *
 * @Auhtor: czyisou@sina.com
 * @Modified By:
 * @Date: Created in : 2:36 PM 2019/12/4
 * @Description:
 */
public class RabbitConfig {
    /**
     * 交换器
     */
    public static final String EXCHANGE_TRACE = "ebike.direct";
    /**
     * 队列
     */
    public static final String PAYMENT_REQUEST = "ebike.payment.request";
    public static final String PAYMENT_RESPONSE = "ebike.payment.response";
    public static final String CHANNEL_EVENT_QUEUE = "ebike.channel.event";
    public static final String REFUND_STOP_RESPONSE = "ebike.refundstop.response";

    /**
     * JSON转换
     *
     * @param connectionFactory
     * @return
     */
    @Bean
    public RabbitTemplate rabbitTemplate(final ConnectionFactory connectionFactory) {
        final RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
        rabbitTemplate.setMessageConverter(new Jackson2JsonMessageConverter());
        return rabbitTemplate;
    }


}
